/**
 * 深克隆
 * @params obj
 * return obj
 */
export function deepClone2(obj) {
  let deepObj = null
  if (
    ['string', 'number', 'boolean', 'undefined', 'symbol'].includes(typeof (obj)) ||
    obj === null
  ) {
    deepObj = obj
    return deepObj
  }

  // 创建对象
  const constructor = obj.constructor || Object
  deepObj = new constructor()
  Object.entries(obj).forEach(([key, val]) => {
    deepObj[key] = deepClone2(val)
  })
  return deepObj
}
/**
 * 节流
 * @params fn 需求执行的函数
 * @params delay 延迟时间
 */
export const debounce = (fn, delay) => {
  let timer = null;
  return (...args) => {
    clearTimeout(timer);
    // timer = null;'
    timer = setTimeout(() => {
      fn.apply(fn, args);
    }, delay);
  };
};

// 日期选择器,禁止选择今天以前的日期
export const disabledDate = (time) => {
  return time.getTime() < Date.now()- 8.64e7;
}